home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_A39DD656C739442EA400D2C15A29A658
< prev
next >
Wrap
Text File
|
2005-01-29
|
2KB
|
70 lines
//pixel shader to sample texture and environment map and mixes with material color
//combines a fixed bump image with a procedurally generated one for tiny ripples
//has projective reflections
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//time since whenever
float time;
//magnitude of ripples (recommend from 0.75f to 1.5f)
float ripMag;
//base texture
sampler sampTex;
//cube texture
sampler sampCube;
//projective reflection texture
sampler sampProjRefl;
//
struct PS_INPUT
{
float2 Tex0 : TEXCOORD0;
float3 EnvTex : TEXCOORD1;
float4 Clr : COLOR;
float3 Pos : TEXCOORD2;
float4 ProjTxt : TEXCOORD3;
};
float4 PShader(PS_INPUT In) : COLOR
{
//calc wave offset 0 and 1
float3 tmpW0sin, tmpW0cos;
sincos(float3(4.0f,4.0f,4.0f)*time+In.Pos,tmpW0sin,tmpW0cos);
float3 normWave0=0.17f*(tmpW0sin+tmpW0cos);
float3 normWave1=sin(tmpW0sin*tmpW0cos+In.Pos.x+In.Pos.y);
//combine waves
float3 normWaveCombined=ripMag * normWave0 * normWave1;
//calc proj text warp
float4 projTxtWaved=In.ProjTxt;
float2 projMod=sin(float2(13.0f,5.0f)*time+.6f*In.Pos.xy)*float2(0.75f,0.025f);
projTxtWaved.xy=In.ProjTxt.xy+projMod;
//calc normal offset for sampling
float3 normOff=normWaveCombined;
//combine env map, color map sample, and projective texture sample
float4 clrPlain=tex2D(sampTex,-0.5f*float3(time,time,time)+In.Tex0);
float4 clrEnv=texCUBE(sampCube,normOff+In.EnvTex);
float4 clrProjRefl=tex2Dproj(sampProjRefl,projTxtWaved);
float4 clr=0.33f*clrPlain + 0.85f*clrEnv + 0.6f*clrProjRefl;
//apply vert color
clr*=In.Clr;
//temp
clr.xyz=clr.xyz*0.01f+normWaveCombined*5;
//set alpha from vert color
clr.a=In.Clr.a;
return clr;
}